
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VueQuillEditor from 'vue-quill-editor';
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
import "../src/css/main.css";
import myDistrict from 'my-district';
import VueAxios from 'vue-axios';
import axios from 'axios';
import api from "./interface/index"
import vshare from 'vshare'

Vue.prototype.$api = api.commonUrl
Vue.use(myDistrict)
Vue.use(VueQuillEditor)
Vue.use(ElementUI);
Vue.use(vshare)
Vue.prototype.$axios = axios;
// 定义全局时间戳过滤器

Vue.config.productionTip = false
Vue.filter('contentText', function (value) {
    // if (!value) return ''
    if (value.length > 30) {
      return value.slice(0, 30) + "...";
    }
    return value;
});
new Vue({
  el: '#app',
  router,
  render: h => h(App),
  components: { App },
  template: '<App/>'
})

// main.js中，axios请求拦截器
axios.interceptors.request.use(config => {
  // 为请求头对象添加token验证的Authorization字段
  config.headers['token'] = window.localStorage.getItem('token') ? window.localStorage.getItem('token') : '';
  return config
})

// 解决bug：页面/路由跳转后，滚动条消失，页面无法滚动
router.afterEach((to, from, next) => {
    document.querySelector("body").setAttribute("style", "overflow: auto !important;")
});
